//战魂数据
function create_zh(){
	var i,j,k,l,m,n,q,r;
	var l_box = document.getElementById("l_box");
	var m_box = document.getElementById("m_box");
	var r_box = document.getElementById("r_box");
	var r_box_c = document.getElementById("r_box_c");
	var patbox = document.getElementById("patbox");
	function box_html(tit,attr,info){
		return '<div class="box_html"><div class="box_tit">'+tit+'</div><div class="box_con"><div class="box_attr">'+attr+'</div>'+info+'</div></div>';
	}
	var m_box_div = {},
		r_box_div = {};
	for(i in db_zh){
		k=db_zh[i];
		l = document.createElement("div");
		l.innerHTML = i;
		l.data = "B" + Math.random();
		l.onclick = function(e){
			var b = m_box_div[this.data];
			for(var i in m_box_div){
				m_box_div[i].style.display = "none";
			}
			b.style.display = "block";
		};
		l_box.appendChild(l);
		m_box_div[l.data] = document.createElement("div");
		m_box_div[l.data].style.display = "none";
		r = document.createElement("div");
		m = document.createElement("div");
		m.innerHTML = i;
		m.style.cssText = "font:24px/32px 微软雅黑,Arial;";
		r.appendChild(m);
		m_box_div[l.data].appendChild(r);
		for(j in k){
			q = document.createElement("div");
			q.odata = k[j];
			q.otitle = j;
			q.className = "abox";
			m = document.createElement("div");
			m.innerHTML = j;
			m.className = "tit";
			q.appendChild(m);
			n = document.createElement("div");
			n.innerHTML = k[j][0];
			n.className = "con";
			q.onclick = function(e){
				var i=0;
				var str = '<font style="font:24px/24px 微软雅黑,Arial;">'+this.otitle+'</font>',tary = [];
				if(this.odata[3]){
					str += '<div class="hr"></div><font color="#FFC8C8">拥有些战魂战宠</font><br>';
					for(i=0;i<this.odata[3].length;i++){
						tary.push( '<a class="patclick" onclick="window.patnamefunc(this);" href="#">' + this.odata[3][i] + '</a>');
					}
					str += tary.join("　") ;
				}
				str += '<div class="hr"></div><font color="#FFC8C8">可激活圣痕前缀</font><br>';
				tary = [];
				for(i=0;i<this.odata[1].length;i++){
					tary.push( "　【" + this.odata[1][i] + "】　" + db_qz[this.odata[1][i]] );
				}
				str += tary.join("<br>");
				if(this.odata[2]){
					str += '<div class="hr"></div><font color="#FFC8C8">战魂组合加成</font><br>';
					for(i=0;i<this.odata[2].length;i++){
						try{
							str += box_html("　【" + this.odata[2][i] + "】", db_zhzh[this.odata[2][i]][0], db_zhzh[this.odata[2][i]][1]);
						}catch(err){
							str += box_html("　【" + this.odata[2][i] + "】", "<font color='red'>缺少数据</font>", "<font color='red'>缺少数据</font>");
						}
					}
				}
				r_box_c.innerHTML = str;
			};
			q.appendChild(n);
			m_box_div[l.data].appendChild(q);
		}
		m_box.appendChild(m_box_div[l.data]);
		var patname = document.getElementById("patname");
		var patzh = document.getElementById("patzh");
		
		var patimg = document.getElementById("patimg");
		
		var patptgj = document.getElementById("patptgj");
		var patzdjn = document.getElementById("patzdjn");
		var patbdjn = document.getElementById("patbdjn");
		var pathdtj = document.getElementById("pathdtj");

		var pat_life = document.getElementById("pat_life");
		var pat_datt = document.getElementById("pat_datt");
		var pat_matt = document.getElementById("pat_matt");
		var pat_ddef = document.getElementById("pat_ddef");
		var pat_mdef = document.getElementById("pat_mdef");

		var pat_pg = document.getElementById("pat_pg");
		var pat_gd = document.getElementById("pat_gd");
		var pat_bj = document.getElementById("pat_bj");
		var pat_rx = document.getElementById("pat_rx");
		var pat_delay = document.getElementById("pat_delay");
		function getImgHTML(ability_name){
			var icon = document.createElement("img");
			icon.style.cssText = "width:48px;height:48px;cursor:pointer;margin:0px 3px;";
			icon.src = "db/img/" + db_ab[ability_name][0];
			icon.setAttribute("ability_name", ability_name);
			icon.setAttribute("onmouseover", "showContent(event,this)");
			icon.setAttribute("onmouseout", 'box_ability.style.display = "none";');
			return icon.outerHTML;
		}
		var box_ability = document.getElementById("box_ability");
		var box_ability_title = document.getElementById("box_ability_title");
		var box_ability_icon = document.getElementById("box_ability_icon");
		var box_ability_content = document.getElementById("box_ability_content");
		window.showContent = function(event,t){
			var name = t.getAttribute("ability_name");
			box_ability_title.innerHTML = "<font color='#FF6496'>" + name + "</font>";
			box_ability_icon.innerHTML = '<img src="db/img//' + db_ab[name][0] + '">';
			box_ability_content.innerHTML = db_ab[name][1];
			box_ability.style.display = "block";
		};
		document.onmousemove = function(event){
			event = event || window.event;
			if(box_ability.style.display=="block"){
				box_ability.style.top = (event.clientY + 32) + "px";
				box_ability.style.right = (document.body.clientWidth - event.clientX + 32) + "px";
			}
		};
		window.patnamefunc = function(t){
			var name = t.innerHTML;
			var i=0,k=[];
			if(db_pat[name]){
				patimg.innerHTML = '<img src="db/img/' + db_pat[name]["img"] + '" width="286" height="280">';
				patname.innerHTML = t.innerHTML;
				patzh.innerHTML = db_pat[name]["战魂"].join("、");
				patptgj.innerHTML = db_pat[name]["普通攻击"];
				patzdjn.innerHTML = getImgHTML(db_pat[name]["主动技能"]);
				for(i=0,k=[];i<db_pat[name]["被动技能"].length;i++){
					k.push(getImgHTML(db_pat[name]["被动技能"][i], db_pat[name]["被动技能"][i]));
				}
				patbdjn.innerHTML = k.join("");
				pathdtj.innerHTML = db_pat[name]["获得途径"].join("<br>");
				patbox.style.display = "block";
				pat_life.innerHTML = db_pat[name]["紫+4"][0];
				pat_datt.innerHTML = db_pat[name]["紫+4"][1];
				pat_matt.innerHTML = db_pat[name]["紫+4"][2];
				pat_ddef.innerHTML = db_pat[name]["紫+4"][3];
				pat_mdef.innerHTML = db_pat[name]["紫+4"][4];
				
				pat_pg.innerHTML = db_pat[name]["紫+4"][5];
				pat_gd.innerHTML = db_pat[name]["紫+4"][6];
				pat_bj.innerHTML = db_pat[name]["紫+4"][7];
				pat_rx.innerHTML = db_pat[name]["紫+4"][8];
				pat_delay.innerHTML = db_pat[name]["紫+4"][9];
			}
		};
	}
}
window.onload = create_zh;
